﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebApplication1.WSDetalhaCliente;

namespace WebApplication1.Account
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
			   
        }

        protected void LoginUser_Authenticate(object sender, AuthenticateEventArgs e)
        {
            WSAutenticacao.Soap_LoginService autenticacao = new WSAutenticacao.Soap_LoginService();
			ClientesImplService clienteService = new WSDetalhaCliente.ClientesImplService();

            var userName = LoginUser.UserName.Trim();
            var password = LoginUser.Password;

            string aut = autenticacao.authenticate(userName, password);

			//Response.Write("aut = " + aut);
            if ("1" == aut.Trim())
            {
                e.Authenticated = true;

                Session["TaLogado"] = true;

				if (Convert.ToBoolean(ConfigurationManager.AppSettings["IsWifi"]))
					clienteService.Url = "http://localhost:8280/clientesWS/clientes2?wsdl";

				Session["ObjetoUsuario"] = clienteService.buscaInformacoesCliente(userName);

				if (Request.QueryString["gbt"] == "1")
					Response.Redirect("~/InformacoesCliente.aspx");
                else
                    Response.Redirect("~/ListaCategorias.aspx");
            }
        }
    }
}
